<?php


namespace app\user\controller;

use app\common\controller\User;

/**
 * 充值
 * Class Recharge
 * @package app\user\controller
 */
class Recharge extends User
{
    /**
     * 微信
     * @return mixed
     */
    public function index()
    {
        $cover_id = model('Ad')->where(['unique_id' => 'wechat_recharge'])->value('cover_id');
        $this->assign('img', get_cover($cover_id, 'path'));

        if ($this->isMobile()) {
            $cover_id = model('Ad')->where(['unique_id' => 'alipay_recharge'])->value('cover_id');
            $this->assign('alipay_img', get_cover($cover_id, 'path'));
        }

        return $this->fetch();
    }

    /**
     * 支付宝
     * @return mixed
     */
    public function pay()
    {
        $cover_id = model('Ad')->where(['unique_id' => 'alipay_recharge'])->value('cover_id');
        $this->assign('img', get_cover($cover_id, 'path'));
        return $this->fetch();
    }

    /**
     * 充值日志
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function log()
    {
        $list = model('UserRecharge')
            ->where(['uid' => $this->uid])
            ->paginate(15, $this->isMobile() ? true : false, $this->request->param());

        $this->assign('list', $list);
        $this->assign('page', $list->render());

        return $this->fetch();
    }

}
